import { getPages } from '../utils/request';
import { get, put, post } from '../utils/request';
import * as selectSrcService from './selectSrcService';

///获取数据列表
export async function getList(input) {
  return getPages(`/app/Material/GetAll`, input.currentPage, input.pageSize, input.queryStr);
}

export async function create(input) {
  return post('/app/Material/Create', { body: JSON.stringify(input) });
}

export async function update(input) {
  return put('/app/Material/Update', { body: JSON.stringify(input) });
}

export async function getItem(id) {
  return get(`/app/Material/Get?id=${id}`);
}

///初始化物料管理相关配置
export async function initConfig(input) {
  if (selectSrcService.Categorys.length < 1) {
    selectSrcService.getCategorySelectList({ pId: 'M', qryStr: '', topNum: 0 });
  }
  if (selectSrcService.MaterialSpecs.length < 1) {
    selectSrcService.getMaterialSpecSelectList({ pId: 'M', qryStr: '', topNum: 0 });
  }
  return [];
}